<!DOCTYPE html>
<html lang="en">
	<head>
		<include file="Index/head" />
	</head>

	<body>
		<include file="Index/header" />

		<div class="main-container" id="main-container">
			<script type="text/javascript">
				try{ace.settings.check('main-container' , 'fixed')}catch(e){}
			</script>

			<div class="main-container-inner">
				<a class="menu-toggler" id="menu-toggler" href="#">
					<span class="menu-text"></span>
				</a>

				<include file="Index/menu" />
				
				<div class="main-content">
					<include file="Index/nav" />

					<div class="page-content">
						
							<!-- /**
							 * 右侧页面begin
							 */ -->
								<div class="row">
									<div class="col-xs-12">
										<div class="table-header">
                                                                                    产品列表  [<a style='color:#ff0000;' href="{:U('Admin/Product/lists',array('if_testreport'=>1))}">未检测产品</a>]
										</div>
										<div class="table-responsive">
											<div id="sample-table-2_wrapper" class="dataTables_wrapper" role="grid">
											<div class="row">
											<div class="col-sm-6">
											<div id="sample-table-2_length" class="dataTables_length">
											<!-- <label>Display 
											<select size="1" name="sample-table-2_length" aria-controls="sample-table-2">
											<option value="10" selected="selected">10</option><option value="25">25</option><option value="50">50</option>
											<option value="100">100</option>
											</select> records
											</label> -->
											</div>
											</div>
											<div class="col-sm-10" style="margin-bottom:-20px;">
											<div class="dataTables_filter" id="sample-table-2_filter">
											
											<p><form action="{:U('Admin/Product/lists')}" method="post">
											产品名: <input type="text" name="product_name" aria-controls="sample-table-2">
											条形码: <input type="text" name="barcode" aria-controls="sample-table-2">
<!--                                                                                        程序匹配数: <input type="text" name="machine_match_count" aria-controls="sample-table-2">
                                                                                        人工匹配数: <input type="text" name="manual_macth_count" aria-controls="sample-table-2">-->
											<input type="submit" value="查询">
											</form>
											</p>
                                                                                        
                                                                                        
											<a href="{:U('Admin/Product/add_product')}">
												<p style="margin-top:20px;"><button type="button" class="btn btn-white">添加产品</button></p>
											</a>
											
											</div>
											</div>
                                                                                        
											</div>
                                                                                        
                                                                                          <div>
                                                                                          <hr/>
                                                                                            <p><form action="{:U('Admin/Product/upload_third_party')}" method="post" enctype="multipart/form-data">
                                                                                            选择导入文件: <input type="file" name="third_data" aria-controls="sample-table-2" style="display:inline;">
                                                                                            

                                                                                            来源: <input name="origin" value="国家食品药品监督管理总局" />
                                                                                            导入标记: <input name="import_remark" value="" />
                                                                                            
                                                                                            <input type="submit" value="导入">
                                                                                            </form>
                                                                                            </p>

                                                                                            <hr/>  
                                                                                        </div>  
                                                                                            
											<table id="sample-table-2" class="table table-striped table-bordered table-hover dataTable" aria-describedby="sample-table-2_info">
												<thead>
													<tr role="row">
													<th  role="columnheader" tabindex="0" aria-controls="sample-table-2" rowspan="1" colspan="1" aria-label="Domain: activate to sort column ascending" >ID</th>
													<th role="columnheader" tabindex="0" aria-controls="sample-table-2" rowspan="1" colspan="1" aria-label="Price: activate to sort column ascending">产品名(全名)</th>
                                                                                                        <th role="columnheader" tabindex="0" aria-controls="sample-table-2" rowspan="1" colspan="1" aria-label="Price: activate to sort column ascending">程序匹配数</th>
                                                                                                        <th role="columnheader" tabindex="0" aria-controls="sample-table-2" rowspan="1" colspan="1" aria-label="Price: activate to sort column ascending">人工匹配数</th>
                                                                                                        <th role="columnheader" tabindex="0" aria-controls="sample-table-2" rowspan="1" colspan="1" aria-label="Price: activate to sort column ascending">扫描次数</th>
													<th  role="columnheader" tabindex="0" aria-controls="sample-table-2" rowspan="1" colspan="1" aria-label="Clicks: activate to sort column ascending">产品名(短名)</th>
													<th  role="columnheader" tabindex="0" aria-controls="sample-table-2" rowspan="1" colspan="1" aria-label="Clicks: activate to sort column ascending">品牌名</th>
													<th  role="columnheader" tabindex="0" aria-controls="sample-table-2" rowspan="1" colspan="1" aria-label="Clicks: activate to sort column ascending">规格</th>
													<th class="" role="columnheader" tabindex="0" aria-controls="sample-table-2" rowspan="1" colspan="1" aria-label="Update: activate to sort column ascending" ><i class="icon-address bigger-110 hidden-480"></i>产品描述</th>
													<th  role="columnheader" tabindex="0" aria-controls="sample-table-2" rowspan="1" colspan="1" aria-label="Domain: activate to sort column ascending">条形码</th>
													<th  role="columnheader" tabindex="0" aria-controls="sample-table-2" rowspan="1" colspan="1" aria-label="Domain: activate to sort column ascending">分类</th>
													<th  role="columnheader" tabindex="0" aria-controls="sample-table-2" rowspan="1" colspan="1" aria-label="Domain: activate to sort column ascending">创建时间</th>
													<th  role="columnheader" tabindex="0" aria-controls="sample-table-2" rowspan="1" colspan="1" aria-label="Domain: activate to sort column ascending">产品类型</th>
													<th class="sorting_disabled" role="columnheader" rowspan="1" colspan="1" aria-label=""></th></tr>
												</thead>
											<tbody role="alert" aria-live="polite" aria-relevant="all">
											<!-- 循环开始出 -->
											<volist name="list" id="vo">
											<tr class="odd">
												<td class=" ">{$vo.id}</td>
												<td class=" ">{$vo.name}</td>
                                                                                                <td class=" ">{$vo.machine_match_count}</td>
                                                                                                <td class=" "><a href="{:U('product2third_part_product',array('id'=>$vo['id']))}">{$vo.manual_macth_count}</a></td>
                                                                                                <td class=" ">{$vo.scan_count}</td>
												<td class=" ">{$vo.shortname}</td>
												<td class=" ">{$vo.brand}</td>
												<td class=" ">{$vo.specification}</td>
												<td class=" ">{$vo.remark}</td>
												<td class=" ">{$vo.barcode}</td>
												<td class=" ">{$vo.classify_name}</td>
												<td class=" ">{$vo.ctime|date="Y-m-d,H:i:s",###}</td>
												<td>
													<if condition="$vo.isfood eq 0">
													<span pid="{$vo.id}" class="btn btn-danger btn-sm tooltip-error" data-rel="popover">其他</span>
													<else/>
													<span pid="{$vo.id}" class="btn btn-success btn-sm tooltip-success" data-rel="popover">食品</span>
													</if>
												</td>
												<td class=" ">
													<div class="visible-md visible-lg hidden-sm hidden-xs action-buttons">
														<!-- <a class="blue" href="#">
															<i class="icon-zoom-in bigger-130" title="详情"></i>
														</a> -->

														<!-- <a class="green" href="{:U('Admin/Product/update_product',array('id'=> $vo['id']))}">
															<i class="icon-pencil bigger-130" title="修改" ></i>
														</a> -->
													
														<a class="green_m" p-id="{$vo.id}" p-name="{$vo.name}" p-shortname="{$vo.shortname}" p-brand="{$vo.brand}" p-specification="{$vo.specification}" p-classify-name="{$vo.classify_name}" p-remark="{$vo.remark}" p-barcode="{$vo.barcode}" href="#">
															<i class="icon-pencil bigger-130" title="修改" ></i>
														</a>

														<a class="red" href="javascript:del_product({$vo.id})">
															<i class="icon-trash bigger-130" title="删除" ></i>
														</a>
													</div>

													<div class="visible-xs visible-sm hidden-md hidden-lg">
														<div class="inline position-relative">
															<button class="btn btn-minier btn-yellow dropdown-toggle" data-toggle="dropdown">
																<i class="icon-caret-down icon-only bigger-120"></i>
															</button>

															<ul class="dropdown-menu dropdown-only-icon dropdown-yellow pull-right dropdown-caret dropdown-close">
																<li>
																	<a href="#" class="tooltip-info" data-rel="tooltip" data-original-title="View">
																		<span class="blue">
																			<i class="icon-zoom-in bigger-120"></i>
																		</span>
																	</a>
																</li>

																<li>
																	<a href="#" class="tooltip-success" data-rel="tooltip" title="" data-original-title="Edit">
																		<span class="green">
																			<i class="icon-edit bigger-120"></i>
																		</span>
																	</a>
																</li>

																<li>
																	<a href="#" class="tooltip-error" data-rel="tooltip" title="" data-original-title="Delete">
																		<span class="red">
																			<i class="icon-trash bigger-120"></i>
																		</span>
																	</a>
																</li>
															</ul>
														</div>
													</div>
												</td>
											</tr>
											</volist>
											<!-- 循环输出结束处 -->
											</tbody>
											</table>
											<div class="row">
												<div class="col-sm-6">
													<div class="dataTables_info" id="sample-table-2_info"></div>
												</div>
												<div class="col-sm-6">
													<div class="dataTables_paginate paging_bootstrap">
														<ul class="pagination">
															{$page}
														</ul>
													</div>
												</div>
											</div>
										</div>
									</div>
								</div>

							<!-- /**
							 * 右侧页面end
							 */ -->
					</div><!-- /.page-content -->
				</div>

			</div><!-- /.main-container-inner  overflow:auto; -->
			<div class="modify_product_div" style="width:60%; overflow:auto; max-height:500px; border:5px solid #307ECC; background-color:#fff; position:fixed; top:100px; right:18%; display:none;">
				<div class="row">
					<div class="col-xs-12">
						<form class="form-horizontal" role="form" action="{:U('Admin/Product/modify_product')}" method="POST" enctype="multipart/form-data">
						<div class="space-4"></div>
						<div class="space-4"></div>
						<div class="space-4"></div>
							<div class="form-group">
								<label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 产品名(全名): </label>
								<div class="col-sm-9">
									<input type="text" name="name" id="form-field-1" placeholder="产品名" class="col-xs-10 col-sm-5 name">
								</div>
							</div>
							<div class="space-4"></div>
							<div class="form-group">
								<label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 产品名(短名): </label>
								<div class="col-sm-9">
									<input type="text" name="shortname" id="form-field-1" placeholder="产品名" class="col-xs-10 col-sm-5 shortname">
								</div>
							</div>
							<div class="space-4"></div>
							<div class="form-group">
								<label class="col-sm-3 control-label no-padding-right" for="form-field-2"> 品牌名: </label>
								<div class="col-sm-9">
									<input type="text" id="form-field-2" placeholder="品牌名" class="col-xs-10 col-sm-5 brand" name="brand">
								</div>
							</div>
							<div class="space-4"></div>
							<div class="form-group">
								<label class="col-sm-3 control-label no-padding-right" for="form-field-2"> 规格: </label>
								<div class="col-sm-9">
									<input type="text" id="form-field-2" class="col-xs-10 col-sm-5 specification" name="specification">
								</div>
							</div>
							<div class="space-4"></div>
							<div class="form-group">
								<label class="col-sm-3 control-label no-padding-right" for="form-field-2"> 分类名: </label>
								<div class="col-sm-9">
									<input type="text" id="classify_name" class="col-xs-10 col-sm-5" name="classify_name">
								</div>
								<label class="col-sm-3 control-label no-padding-right" for="form-field-2"> </label>
								<div class="col-sm-9">
									<select name="classify_id" id="select_classify_id" class="col-sm-5" hidden="hidden">
									</select>
								</div>
							</div>

							<div class="form-group">
								<label class="col-sm-3 control-label no-padding-right" for="form-field-2"> 条形码: </label>
								<div class="col-sm-9">
									<input type="text" id="form-field-2" placeholder="条形码" class="col-xs-10 col-sm-5 barcode" name="barcode">
								</div>
							</div>

							<div class="form-group">
								<label class="col-sm-3 control-label no-padding-right" for="form-field-2"> 产品描述: </label>
								<div class="col-sm-4">
									<div class="widget-box">
										<div class="widget-header widget-header-small header-color-blue">  </div>
										<div class="widget-body">
											<div class="widget-main no-padding">
												<textarea class="span12 md-input remark" name="remark" data-provide="markdown" rows="10" style="resize: none;"></textarea>
											</div>
											<div class="widget-toolbox padding-4 clearfix">
												<div class="btn-group pull-left">
												</div>
												<div class="btn-group pull-right">
												</div>
											</div>
										</div>
									</div>
								</div>
							</div>
							<div class="space-4"></div>
							<div class="form-group">
							<label class="col-sm-3 control-label no-padding-right" for="form-field-2"></label>
							&nbsp;&nbsp;&nbsp;
							<div class="space-4"></div>
							</div>
							<input type="text" name="product_id" class="product_id" hidden="hidden" />
							<div class="clearfix form-actions">
								<div class="col-md-offset-3 col-md-9">
									<button class="btn btn-info" type="submit">
										<i class="icon-ok bigger-110"></i>
										修改
									</button>									
								&nbsp; &nbsp; &nbsp;
								<a href="javascript:hide_product_div();">
									<button class="btn" type="button">
										<i class="icon-undo bigger-110"></i>
										撤销
									</button>
								</a>
								</div>
							</div>
							<div class="hr hr-24"></div>
							</div><!-- /row -->
						</form>
				</div>

			</div>

			<a href="#" id="btn-scroll-up" class="btn-scroll-up btn btn-sm btn-inverse">
				<i class="icon-double-angle-up icon-only bigger-110"></i>
			</a>
		</div><!-- /.main-container -->
		<include file="Index/footer" />
		<script type="text/javascript">
		function del_product(id)
		{
			var r= confirm('确定删除该产品?');
			if(r)
			{
				var url = "{:U('Admin/Product/del_product')}";
				var id = id;
				$.ajax({
					type: 'post',
					url: url,
					data: {id:id},
					dataType: 'json',
					success: function(data){
						if(data==1){
							window.location.href="{:U('Admin/Product/lists')}";
						}
					}
				});
			}
			else
			{
				return false;
			}
		}

		$(".green_m").bind('click',function(){

			var name = $(this).attr('p-name')
			var shortname = $(this).attr('p-shortname');
			var brand = $(this).attr('p-brand');
			var specification = $(this).attr('p-specification');
			var classify_name = $(this).attr('p-classify-name');
			var remark = $(this).attr('p-remark');
			var barcode = $(this).attr('p-barcode');
			var id = $(this).attr('p-id');

			$(".name").val(name);
			$(".shortname").val(shortname);
			$(".brand").val(brand);
			$(".specification").val(specification);
			$("#classify_name").val(classify_name);
			$(".remark").val(remark);
			$(".barcode").val(barcode);
			$(".product_id").val(id);
			$(".modify_product_div").show();
		});

		function modify_product(id,name,shortname,brand,specification,classify_name,remark,barcode){
			$(".name").val(name);
			$(".shortname").val(shortname);
			$(".brand").val(brand);
			$(".specification").val(specification);
			$("#classify_name").val(classify_name);
			$(".remark").val(remark);
			$(".barcode").val(barcode);
			$(".product_id").val(id);
			$(".modify_product_div").show();

		}

		function hide_product_div(){

			$(".modify_product_div").hide();
		}


		$("#classify_name").bind('input propertychange',function(){
			$("#select_classify_id").children('option').remove();
			$("#select_classify_id").attr('size',0);
			$("#select_classify_id").hide();
			var classify_name = $(this).val();

			var url = "{:U('Admin/Product/select_classify_ajax')}";
			$.ajax({
				type: 'post',
				url: url,
				data: {classify_name:classify_name},
				dataType: 'json',
				success: function(data){
					var str = '';
					$.each(data,function(k,v){

						str += "<option value='"+v['id']+"'>"+v['name']+"</option>";
					});

					var str_len = data.length;
					$("#select_classify_id").attr('size',str_len);
					$("#select_classify_id").show();
					$("#select_classify_id").append(str);
				}
			});
		});

		$("#select_classify_id").bind('click',function(){
			var classify_name = $(this).find("option:selected").text();
			$("#classify_name").val(classify_name);
			$("#select_classify_id").hide();
		});

		$(".tooltip-error").bind('click',function(){
			var isfood = 1;
			var pid = $(this).attr('pid');
			var now_url = window.location.href;
			var url = "{:U('Admin/Product/modify_product_isfood')}";
			$.ajax({
				type:'post',
				url:url,
				data:{isfood:isfood,pid:pid},
				dataType:'json',
				success:function(data){
					if(data===1){

						window.location.href = now_url;
					}
				}
			});
		});
		$(".tooltip-success").bind('click',function(){
			var isfood = 0;
			var pid = $(this).attr('pid');
			var now_url = window.location.href;
			var url = "{:U('Admin/Product/modify_product_isfood')}";
			$.ajax({
				type:'post',
				url:url,
				data:{isfood:isfood,pid:pid},
				dataType:'json',
				success:function(data){
					if(data===1){

						window.location.href = now_url;
					}
				}
			});
		});
		</script>
	</body>
</html>
